package net.wanho.config;

import net.wanho.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class AuthConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加拦截器
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
//                .excludePathPatterns("/captchaImage", "/login", "/captchaLogin", "/logout", "/file/upload", "/alipay/notify")
//                // 放行knife4j
//                .excludePathPatterns("/doc.html", "/webjars/**", "/v2/**", "/swagger-resources/**", "/statics/**");
                .excludePathPatterns(
                        // 原有的放行路径
                        "/captchaImage",
                        "/login",
                        "/captchaLogin",
                        "/logout",
                        "/file/upload",
                        "/alipay/notify",
                        "/alipay/pay",
                        "/smsCode",
                        "/smsLogin",
                        "/weather",
                        "/suppliers/export",
                        // 新增：静态资源放行
                        "/statics/**",
                        "/images/**",
                        "/upload/**",
                        "/**/*.jpg",
                        "/**/*.jpeg",
                        "/**/*.png",
                        "/**/*.gif",
                        "/**/*.bmp",
                        "/**/*.webp",
                        "/**/*.css",
                        "/**/*.js");
    }

    ;
}